populate a popup window using php and javascript

populate a popup window using php and javascript

am 17.10.2007 17:04:20 von jsd219

Hi all, I know this is an elementary question but I am at a loss. I
have googled and searched but can not find the answer. My knowledge of
javascript is infant at best and php is novice. I have a database
driven site coded in php, on the 'display_trip.php' page the user sees
a list of possible trips and with dates. I would like to code it so
when the user clicks on one of the trips a popup window opens with the
value stored in the content field of the database for that particular
trip. I have figured out how to create a popup window for images but
not how to pass info from a query.

below are snippits of my code:

File Name: display_trip.php
------------------------------------------------------------ ------------------------------------------------
as you can see I am calling the content field in my query.

$query = "SELECT TRIP_ID, TRIP_TITLE, TRIP_THUMB, TRIP_CONTENT
FROM TRIPS
WHERE TRIP_ID != ''";
------------------------------------------------------------ ------------------------------------------------
$chref = " ------------------------------------------------------------ -----------------------------------------------
here is part of my echo statement to create the link:

"" . "  " . "{$chref}{$row['TRIP_ID']}')
\">" . "{$row['TRIP_TITLE']} " . "" .
------------------------------------------------------------ ------------------------------------------------


File Name: header.php file
------------------------------------------------------------ ------------------------------------------------
here is my javascript function from my header.php

function OpenEvent(id)
{
window.open ('SOMETHING NEED TO GO HERE' + id, 'newwindow',
config='height=450, width=550, toolbar=no, menubar=no, scrollbars=no,
resizable=no, location=no, directories=no, status=no')
}
------------------------------------------------------------ ---------------------------------------------------
Any help would be greatly appreciated

God bless
jason

Re: populate a popup window using php and javascript

am 17.10.2007 17:56:48 von Jerry Stuckle

jsd219 wrote:
> Hi all, I know this is an elementary question but I am at a loss. I
> have googled and searched but can not find the answer. My knowledge of
> javascript is infant at best and php is novice. I have a database
> driven site coded in php, on the 'display_trip.php' page the user sees
> a list of possible trips and with dates. I would like to code it so
> when the user clicks on one of the trips a popup window opens with the
> value stored in the content field of the database for that particular
> trip. I have figured out how to create a popup window for images but
> not how to pass info from a query.
>
> below are snippits of my code:
>
> File Name: display_trip.php
> ------------------------------------------------------------ ------------------------------------------------
> as you can see I am calling the content field in my query.
>
> $query = "SELECT TRIP_ID, TRIP_TITLE, TRIP_THUMB, TRIP_CONTENT
> FROM TRIPS
> WHERE TRIP_ID != ''";
> ------------------------------------------------------------ ------------------------------------------------
> $chref = "
> ------------------------------------------------------------ -----------------------------------------------
> here is part of my echo statement to create the link:
>
> "" . "  " . "{$chref}{$row['TRIP_ID']}')
> \">" . "{$row['TRIP_TITLE']} " . "" .
> ------------------------------------------------------------ ------------------------------------------------
>
>
> File Name: header.php file
> ------------------------------------------------------------ ------------------------------------------------
> here is my javascript function from my header.php
>
> function OpenEvent(id)
> {
> window.open ('SOMETHING NEED TO GO HERE' + id, 'newwindow',
> config='height=450, width=550, toolbar=no, menubar=no, scrollbars=no,
> resizable=no, location=no, directories=no, status=no')
> }
> ------------------------------------------------------------ ---------------------------------------------------
> Any help would be greatly appreciated
>
> God bless
> jason
>
>

You can't do it in PHP itself. You need Javascript or Ajax (which uses
javascript).

Try comp.lang.javascript.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: populate a popup window using php and javascript

am 17.10.2007 18:14:31 von Courtney

jsd219 wrote:
> Hi all, I know this is an elementary question but I am at a loss. I
> have googled and searched but can not find the answer. My knowledge of
> javascript is infant at best and php is novice. I have a database
> driven site coded in php, on the 'display_trip.php' page the user sees
> a list of possible trips and with dates. I would like to code it so
> when the user clicks on one of the trips a popup window opens with the
> value stored in the content field of the database for that particular
> trip. I have figured out how to create a popup window for images but
> not how to pass info from a query.
>
> below are snippits of my code:
>
> File Name: display_trip.php
> ------------------------------------------------------------ ------------------------------------------------
> as you can see I am calling the content field in my query.
>
> $query = "SELECT TRIP_ID, TRIP_TITLE, TRIP_THUMB, TRIP_CONTENT
> FROM TRIPS
> WHERE TRIP_ID != ''";
> ------------------------------------------------------------ ------------------------------------------------
> $chref = "
> ------------------------------------------------------------ -----------------------------------------------
> here is part of my echo statement to create the link:
>
> "" . "  " . "{$chref}{$row['TRIP_ID']}')
> \">" . "{$row['TRIP_TITLE']} " . "" .
> ------------------------------------------------------------ ------------------------------------------------
>
>
> File Name: header.php file
> ------------------------------------------------------------ ------------------------------------------------
> here is my javascript function from my header.php
>
> function OpenEvent(id)
> {
> window.open ('SOMETHING NEED TO GO HERE' + id, 'newwindow',
> config='height=450, width=550, toolbar=no, menubar=no, scrollbars=no,
> resizable=no, location=no, directories=no, status=no')
> }
> ------------------------------------------------------------ ---------------------------------------------------
> Any help would be greatly appreciated
>
> God bless
> jason
>


Never mind God, jason, this is a few snippets from some code I wrote
last night. It is more or less what you want.

First the PHP that sets up a clickable link. I don't use URLS as such,
just a clickable field, that changes color when the mouse moves over it.
That in the style sheet - the colors. I prefer to use this rather than a
URL as it gives me a bit more choice on how I actually invoke the popup
and get a signal back from it. In my case it actually may create change
in the database which means I can force a reload if someone does a
database form submit in the child process...


printf (" onclick=\"subedit('%s?id=%d')\" onmouseover=\"this.className='s4'\"
onmouseout=\"this.className='s3'\">%s
\n",
isakit($product_id[$i])? "kitedit.php":"product_edit.php",
$product_id[$i],
$partname[$i]

In practice this generates something that looks like this in the actual
output HTML.


onclick="subedit('product_edit.php?id=327')"
onmouseover="this.className='s4'" onmouseout="this.className='s3'">part
name


Noe that the actual parameter passing is the '?id=327' bit
So now you need a javascript function to open a pop up window and invoke
the file - on this case 'product_edit.php' and pass the id=327 part to it.

?>



Thanks to some nice people in the comp.lang.javascript forum, this is
pretty tidy and always opens a new window, even if the parent is set to
open a new tab. Its a bit browser dependent., so test..test..test..


Note that any time you open a second window, it will replace the first
one as both are called 'kitedit' - this is the sub-window's NAME in
javascript. If it doesn't exist a new one is created,if it does it
overwrites the existing one. I have made it resizable and it can have
scrollbars, as I need these in many cases.


All my windows have the following code in them so that when they are
called from a parent window, they will force a refresh on it if they
exit, or indeed if they submit a load of data to the database..this
means that changes made by spawned child windows operate in the main
window instantly:-




You may not need this. I do as typically the user is editing one bit and
finds he needs something that isn't there..so he can add it via a popup
subswindow and magically it IS there..but it does slow things down a bit.


Ok that's nearly all the bits you need except the final bit ..How to get
the variable passed by the '?id=327' bit

In the child (popup) PHP file thats simple

$id=$_GET['id'];

will load 327 int the php variable $id..when the php script is invoked
as URL "product_edit.php?id=327"

Hope that all helps. Its shit being a newbie isn't it?

Re: populate a popup window using php and javascript

am 17.10.2007 22:29:19 von jsd219

On Oct 17, 10:56 am, Jerry Stuckle wrote:
> jsd219 wrote:
> > Hi all, I know this is an elementary question but I am at a loss. I
> > have googled and searched but can not find the answer. My knowledge of
> > javascript is infant at best and php is novice. I have a database
> > driven site coded in php, on the 'display_trip.php' page the user sees
> > a list of possible trips and with dates. I would like to code it so
> > when the user clicks on one of the trips a popup window opens with the
> > value stored in the content field of the database for that particular
> > trip. I have figured out how to create a popup window for images but
> > not how to pass info from a query.
>
> > below are snippits of my code:
>
> > File Name: display_trip.php
> > ------------------------------------------------------------ ------------------------------------------------
> > as you can see I am calling the content field in my query.
>
> > $query = "SELECT TRIP_ID, TRIP_TITLE, TRIP_THUMB, TRIP_CONTENT
> > FROM TRIPS
> > WHERE TRIP_ID != ''";
> > ------------------------------------------------------------ ------------------------------------------------
> > $chref = "
> > ------------------------------------------------------------ -----------------------------------------------
> > here is part of my echo statement to create the link:
>
> > "" . "  " . "{$chref}{$row['TRIP_ID']}')
> > \">" . "{$row['TRIP_TITLE']} " . "" .
> > ------------------------------------------------------------ ------------------------------------------------
>
> > File Name: header.php file
> > ------------------------------------------------------------ ------------------------------------------------
> > here is my javascript function from my header.php
>
> > function OpenEvent(id)
> > {
> > window.open ('SOMETHING NEED TO GO HERE' + id, 'newwindow',
> > config='height=450, width=550, toolbar=no, menubar=no, scrollbars=no,
> > resizable=no, location=no, directories=no, status=no')
> > }
> > ------------------------------------------------------------ ---------------------------------------------------
> > Any help would be greatly appreciated
>
> > God bless
> > jason
>
> You can't do it in PHP itself. You need Javascript or Ajax (which uses
> javascript).
>
> Try comp.lang.javascript.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================

I have also posted this in comp.lang.javascript. I chose to post here
as well because I am using php with javascript.

Re: populate a popup window using php and javascript

am 17.10.2007 22:47:20 von Jerry Stuckle

jsd219 wrote:
> On Oct 17, 10:56 am, Jerry Stuckle wrote:
>> jsd219 wrote:
>>> Hi all, I know this is an elementary question but I am at a loss. I
>>> have googled and searched but can not find the answer. My knowledge of
>>> javascript is infant at best and php is novice. I have a database
>>> driven site coded in php, on the 'display_trip.php' page the user sees
>>> a list of possible trips and with dates. I would like to code it so
>>> when the user clicks on one of the trips a popup window opens with the
>>> value stored in the content field of the database for that particular
>>> trip. I have figured out how to create a popup window for images but
>>> not how to pass info from a query.
>>> below are snippits of my code:
>>> File Name: display_trip.php
>>> ------------------------------------------------------------ ------------------------------------------------
>>> as you can see I am calling the content field in my query.
>>> $query = "SELECT TRIP_ID, TRIP_TITLE, TRIP_THUMB, TRIP_CONTENT
>>> FROM TRIPS
>>> WHERE TRIP_ID != ''";
>>> ------------------------------------------------------------ ------------------------------------------------
>>> $chref = "
>>> ------------------------------------------------------------ -----------------------------------------------
>>> here is part of my echo statement to create the link:
>>> "" . "  " . "{$chref}{$row['TRIP_ID']}')
>>> \">" . "{$row['TRIP_TITLE']} " . "" .
>>> ------------------------------------------------------------ ------------------------------------------------
>>> File Name: header.php file
>>> ------------------------------------------------------------ ------------------------------------------------
>>> here is my javascript function from my header.php
>>> function OpenEvent(id)
>>> {
>>> window.open ('SOMETHING NEED TO GO HERE' + id, 'newwindow',
>>> config='height=450, width=550, toolbar=no, menubar=no, scrollbars=no,
>>> resizable=no, location=no, directories=no, status=no')
>>> }
>>> ------------------------------------------------------------ ---------------------------------------------------
>>> Any help would be greatly appreciated
>>> God bless
>>> jason
>> You can't do it in PHP itself. You need Javascript or Ajax (which uses
>> javascript).
>>
>> Try comp.lang.javascript.
>>
>
> I have also posted this in comp.lang.javascript. I chose to post here
> as well because I am using php with javascript.
>
>

Then:

1. Cross-post, don't multi-pose.
2. So then, what's your PHP question?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================